package com.resto.scm.web.util;

import com.resto.brand.core.util.MQSetting;
import java.math.BigDecimal;
import java.util.HashMap;
import java.util.Map;
import static com.resto.brand.core.util.HttpClient.doPostAnsc;
import static com.resto.brand.core.util.LogUtils.url;

/**
日志模板
 */
public class LogTemplateUtils {

    //日志类型
  public static final String POSTYPE = "posAction";
  public static final String USERTYPE="UserAction";
  public static final String ORDERTYPE="orderAction";

  public static final String DAYSMSTYPE="daySmsAction";

  public  static  final String THIRDTYPE = "thirdAction";

  public static final String SHOPTYPE="shopAction";      //记录shop端操作记录

    //模板map
    public static  Map getOrderBaseMap(String brandName,String id,String logType){
        //注:如果是id是customerId 则logType传userAction 如果是orderId则传orderActoin 如果是shopDetailId则传posAction
        //id是telephone传daySmsAction
        Map map = new HashMap(4);
        map.put("brandName",brandName);
        map.put("fileName",id);
        map.put("type",logType);
        return  map;
    }


    //记录订单支付项 2017-03-27
    //支付项---等位红包支付
      public  static  void getWaitMoneyLogByOrderType(String brandName, String orderId, BigDecimal payValue){
          Map waitPayMap=getOrderBaseMap(brandName,orderId,ORDERTYPE);
          waitPayMap.put("content", "订单:"+orderId+"使用等位红包支付了：" + payValue +",请求服务器地址为:" + MQSetting.getLocalIP());
          doPostAnsc(url, waitPayMap);
      }

      //支付项---优惠券
    public static void getCouponByOrderType(String brandName, String id, BigDecimal payValue) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        map.put("content", "订单:"+id+"订单使用优惠券支付了：" + payValue +",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url, map);
    }

    //支付项---红包(余额)支付 在AccountServeImpl中payOrder
    public static void getAccountByOrderType(String brandName, String id, BigDecimal payValue) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        map.put("content", "订单:" + id + "订单使用余额(红包)支付了:"+payValue+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url, map);
    }

    //支付项---银联
    public static void getBankByOrderType(String brandName, String id, BigDecimal payValue) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        map.put("content", "订单:" + id + "订单使用银行卡支付了:"+payValue+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url, map);
    }

    //现金支付
    public static void getMoneyByOrderType(String brandName, String id, BigDecimal payValue) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        map.put("content", "订单:" + id + "订单使用现金卡支付了:"+payValue+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url, map);
    }

    //充值余额支付
    public static void getChargeByOrderType(String brandName, BigDecimal payValue, String id) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        map.put("content", "订单:" + id + "订单使用了充值余额支付了:"+payValue+",请求服务器地址为:" + MQSetting.getLocalIP());
    }

    //充值赠送余额支付
    public static void getChargeRewardByOrderType(String brandName, BigDecimal payValue, String id) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        map.put("content", "订单:" + id + "订单使用了充值赠送余额支付了:"+payValue+",请求服务器地址为:" + MQSetting.getLocalIP());
    }




    //父订单打印
    public static void getParentOrderPrintSuccessByOrderType(String brandName, String id,Integer status) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        if(1==status||0==status){
            map.put("content", "订单:" + id + "打印成功，订单为主订单，允许加菜---是消费清单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }else {
            map.put("content", "订单:" + id + "打印成功，订单为主订单，允许加菜---是结账单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }
        doPostAnsc(url, map);
    }

    //子订单打印
    public static void getChildOrderPrintSuccessByOrderType(String brandName, String id,Integer status) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        if(1==status||0==status){
            map.put("content", "订单:" + id + "打印成功，订单为子订单---是消费清单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }else {
            map.put("content", "订单:" + id + "打印成功，订单为子订单---是结账清单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }

        doPostAnsc(url, map);
    }

    /**
     * 记录自动取消订单
     * @param brandName
     * @param id
     * @param auto
     */
    public static void getAutoCancleOrderByOrderType(String brandName, String id, Boolean auto) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
          if(null!=auto&&auto){
              map.put("content", "订单:" + id + "取消订单成功--是2小时自动取消订单"+",请求服务器地址为:" + MQSetting.getLocalIP());
          }else {
              map.put("content", "订单:" + id + "取消订单成功--是用户自己取消未支付"+",请求服务器地址为:" + MQSetting.getLocalIP());
          }
        doPostAnsc(url, map);
    }


    /**
     * 记录拒绝订单
     * @param brandName
     * @param orderId
     */
    public static void cancelOrderByOrderType(String brandName, String orderId) {
        Map map=getOrderBaseMap(brandName,orderId,ORDERTYPE);
        map.put("content", "订单:" +orderId + "在pos端被拒绝,请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    /**
     * 记录订单被叫号
     * @param brandName
     * @param id
     */
    public static void getCallNumber(String brandName, String id) {
        Map map=getOrderBaseMap(brandName,id,ORDERTYPE);
        map.put("content", "订单:" +id + "订单被叫号,请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }



    //记录orderAction end-------------------------------------------------------------


    //记录userAction begin----------------------------------------------------------
    //支付项---等位红包支付
    public  static  void getWaitMoneyLogByUserType(String brandName, String orderId, BigDecimal payValue,String nickName){
        Map map=getOrderBaseMap(brandName,orderId,USERTYPE);
        map.put("content", "用户:"+nickName+"使用等位红包支付了：" +payValue +"订单Id为:"+orderId+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url, map);
    }

    //优惠券支付
    public static void getCouponByUserType(String brandName, String id, String nickname, BigDecimal payValue) {
        // CustomerCouponPaymap.put("content", "用户:"+customer.getNickname()+"使用优惠券支付了：" + item.getPayValue() +"订单Id为:"+order.getId()+",请求服务器地址为:" + MQSetting.getLocalIP());
        Map map = getOrderBaseMap(brandName,id,USERTYPE);
        map.put("content", "用户:"+nickname+"使用优惠券支付了：" +payValue +"订单Id为:"+id+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url, map);
    }

    //余额(红包)支付
    public static void getAccountByUserType(String brandName, String id, String nickname, BigDecimal payValue) {
        Map map=getOrderBaseMap(brandName,id,USERTYPE);
        map.put("content", "用户:"+nickname+"使用余额(红包)支付了:"+payValue+"订单Id为:"+id+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    //银行卡支付
    public static void getBankByUserType(String brandName, String id, String nickname, BigDecimal payValue) {
        Map map=getOrderBaseMap(brandName,id,USERTYPE);
        map.put("content", "用户:"+nickname+"使用银行卡支付了:"+payValue+"订单Id为:"+id+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    //现金支付
    public static void getMoneyByUserType(String brandName, String id, String nickname, BigDecimal payValue) {
        Map map=getOrderBaseMap(brandName,id,USERTYPE);
        map.put("content", "用户:"+nickname+"使用现金支付了:"+payValue+"订单Id为:"+id+",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }



    //记录posAction begin--------------------------------------------------------
    public static void getParentOrderPrintSuccessByPOSType(String brandName, String id,Integer status) {
        Map map=getOrderBaseMap(brandName,id,POSTYPE);
        if(1==status||0==status){
            map.put("content", "订单:" + id + "打印成功，订单为主订单，允许加菜---是消费清单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }else {
            map.put("content", "订单:" + id + "打印成功，订单为主订单，允许加菜---是结账单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }
    }

    public static void getChildOrderPrintSuccessByPOSType(String brandName, String id,Integer status) {
        Map map=getOrderBaseMap(brandName,id,POSTYPE);
        if(1==status||0==status){
            map.put("content", "订单:" + id + "打印成功，订单为子订单 --是消费清单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }else {
            map.put("content", "订单:" + id + "打印成功，订单为子订单---是结账清单"+",请求服务器地址为:" + MQSetting.getLocalIP());
        }
        doPostAnsc(url,map);
    }

    public static void cancleOrderByPosType(String brandName, String name,String orderId) {
        Map map=getOrderBaseMap(brandName,name,POSTYPE);
        map.put("content", "店铺:"+name+"在pos端执行拒绝订单:" + orderId + ",请求服务器地址为:" + MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }


    //记录 posAction end---------------------------------------------------------

    //记录每日短信
    public static void  dayMessageSms(String brandName,String shopName,String telephone,String result){
        Map map=getOrderBaseMap(brandName,telephone,DAYSMSTYPE);
        map.put("content","发送日结短信短信推送店铺为:"+shopName+"发送短信返回的内容为:"+result+"请求服务器地址:"+MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    //记录 shopAction  start ---------------------------------------
    public static void  shopDeatilEdit(String brandName,String shopName,String result){
        Map map=getOrderBaseMap(brandName,shopName,SHOPTYPE);
        map.put("content","当前登录账号为"+result+"，修改了" + shopName + "店铺设置信息。请求服务器地址:"+MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    public static void  brandSettingEdit(String brandName,String shopName,String result){
        Map map=getOrderBaseMap(brandName, shopName,SHOPTYPE);
        map.put("content","当前登录账号为"+result+"，修改了" + shopName + "品牌参数设置信息。请求服务器地址:"+MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    public static void  articleEdit(String brandName,String shopName,String result){
        Map map=getOrderBaseMap(brandName, shopName,SHOPTYPE);
        map.put("content","当前登录账号为"+result+"，修改了" + shopName + "店铺下菜品设置。请求服务器地址:"+MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    public static void  shopUserLogin(String brandName,String shopName,String result){
        Map map=getOrderBaseMap(brandName, shopName,SHOPTYPE);
        map.put("content","当前登录账号为"+result+"，登录了" + shopName + "店铺。请求服务器地址:"+MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }

    public static void  shopUserLogout(String brandName,String shopName,String result){
        Map map=getOrderBaseMap(brandName, shopName,SHOPTYPE);
        map.put("content","当前登录账号为"+result+"，退出了" + shopName + "店铺。请求服务器地址:"+MQSetting.getLocalIP());
        doPostAnsc(url,map);
    }
}
